<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Excel导出性能优化指南</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
        }
        .number-circle {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            width: 48px;
            height: 48px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            color: white;
            font-weight: bold;
            font-size: 20px;
        }
        .section-title {
            position: relative;
            padding-left: 20px;
        }
        .section-title::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 4px;
            height: 24px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 2px;
        }
        .highlight-box {
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            border-left: 4px solid #667eea;
        }
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 2rem 0;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-6">
        <div class="max-w-6xl mx-auto">
            <div class="text-center">
                <h1 class="text-5xl font-bold mb-6" style="font-family: 'Noto Serif SC', serif;">
                    Excel 导出性能优化指南
                </h1>
                <p class="text-xl mb-8 opacity-90 max-w-3xl mx-auto">
                    当数据量庞大时，Excel 导出可能变得异常缓慢。本指南将从多个维度全面提升您的 Excel 导出性能，让用户体验更上一层楼。
                </p>
                <div class="flex justify-center space-x-8 text-sm">
                    <div class="flex items-center">
                        <i class="fas fa-rocket mr-2"></i>
                        <span>性能提升</span>
                    </div>
                    <div class="flex items-center">
                        <i class="fas fa-memory mr-2"></i>
                        <span>内存优化</span>
                    </div>
                    <div class="flex items-center">
                        <i class="fas fa-code mr-2"></i>
                        <span>最佳实践</span>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="max-w-6xl mx-auto px-6 py-12">
        <!-- Introduction -->
        <div class="highlight-box p-6 rounded-lg mb-12">
            <p class="text-gray-700 leading-relaxed">
                在实际项目中，导出 Excel 文件是一个常见但充满挑战的任务。特别是当数据量庞大时，导出速度可能变得异常缓慢，不仅影响用户体验，还可能对系统性能产生负面影响。因此，优化 Excel 文件导出的速度至关重要。
            </p>
        </div>

        <!-- Performance Optimization Diagram -->
        <div class="bg-white rounded-lg shadow-lg p-8 mb-12">
            <h2 class="text-2xl font-bold mb-6 text-center text-gray-800">Excel 导出优化架构图</h2>
            <div class="mermaid">
                graph TD
                    A[Excel导出优化] --> B[数据处理优化]
                    A --> C[技术选型]
                    A --> D[系统架构优化]
                    
                    B --> B1[高效查询]
                    B --> B2[数据分页]
                    B --> B3[按需加载]
                    
                    C --> C1[EasyExcel]
                    C --> C2[流式API]
                    C --> C3[文件格式选择]
                    
                    D --> D1[异步处理]
                    D --> D2[分布式处理]
                    D --> D3[负载均衡]
                    
                    style A fill:#667eea,stroke:#fff,stroke-width:2px,color:#fff
                    style B fill:#9f7aea,stroke:#fff,stroke-width:2px,color:#fff
                    style C fill:#9f7aea,stroke:#fff,stroke-width:2px,color:#fff
                    style D fill:#9f7aea,stroke:#fff,stroke-width:2px,color:#fff
            </div>
        </div>

        <!-- Optimization Strategies -->
        <div class="grid grid-cols-1 md:grid-cols-2 gap-8 mb-12">
            <!-- Strategy 1 -->
            <div class="bg-white rounded-lg shadow-lg p-6 card-hover">
                <div class="flex items-start mb-4">
                    <div class="number-circle mr-4">1</div>
                    <div class="flex-1">
                        <h3 class="text-xl font-bold mb-2 section-title">优化数据生成过程</h3>
                    </div>
                </div>
                <div class="space-y-3 text-gray-700">
                    <div class="flex items-start">
                        <i class="fas fa-database text-purple-600 mt-1 mr-3"></i>
                        <div>
                            <strong>数据处理方式：</strong>确保数据源查询高效，使用适当的索引，避免全表扫描。
                        </div>
                    </div>
                    <div class="flex items-start">
                        <i class="fas fa-layer-group text-purple-600 mt-1 mr-3"></i>
                        <div>
                            <strong>数据分页：</strong>将大数据量分成多个批次处理，降低内存占用。
                        </div>
                    </div>
                </div>
            </div>

            <!-- Strategy 2 -->
            <div class="bg-white rounded-lg shadow-lg p-6 card-hover">
                <div class="flex items-start mb-4">
                    <div class="number-circle mr-4">2</div>
                    <div class="flex-1">
                        <h3 class="text-xl font-bold mb-2 section-title">使用高效的 Excel 库</h3>
                    </div>
                </div>
                <div class="space-y-3 text-gray-700">
                    <div class="flex items-start">
                        <i class="fas fa-tools text-purple-600 mt-1 mr-3"></i>
                        <div>
                            <strong>选择合适的库：</strong>EasyExcel 在处理大数据量时表现优异。
                        </div>
                    </div>
                    <div class="flex items-start">
                        <i class="fas fa-stream text-purple-600 mt-1 mr-3"></i>
                        <div>
                            <strong>流式 API：</strong>避免一次性加载所有数据到内存中。
                        </div>
                    </div>
                </div>
            </div>

            <!-- Strategy 3 -->
            <div class="bg-white rounded-lg shadow-lg p-6 card-hover">
                <div class="flex items-start mb-4">
                    <div class="number-circle mr-4">3</div>
                    <div class="flex-1">
                        <h3 class="text-xl font-bold mb-2 section-title">减少内存消耗</h3>
                    </div>
                </div>
                <div class="space-y-3 text-gray-700">
                    <div class="flex items-start">
                        <i class="fas fa-memory text-purple-600 mt-1 mr-3"></i>
                        <div>
                            <strong>按需加载：</strong>使用流式写入方法逐行写入数据。
                        </div>
                    </div>
                    <div class="flex items-start">
                        <i class="fas fa-cog text-purple-600 mt-1 mr-3"></i>
                        <div>
                            <strong>内存设置：</strong>调整 JVM 参数 -Xmx 和 -Xms。
                        </div>
                    </div>
                </div>
            </div>

            <!-- Strategy 4 -->
            <div class="bg-white rounded-lg shadow-lg p-6 card-hover">
                <div class="flex items-start mb-4">
                    <div class="number-circle mr-4">4</div>
                    <div class="flex-1">
                        <h3 class="text-xl font-bold mb-2 section-title">优化 Excel 文件格式</h3>
                    </div>
                </div>
                <div class="space-y-3 text-gray-700">
                    <div class="flex items-start">
                        <i class="fas fa-file-excel text-purple-600 mt-1 mr-3"></i>
                        <div>
                            <strong>文件格式选择：</strong>XLSX 格式比 XLS 更高效。
                        </div>
                    </div>
                    <div class="flex items-start">
                        <i class="fas fa-palette text-purple-600 mt-1 mr-3"></i>
                        <div>
                            <strong>减少格式设置：</strong>避免过多的字体、颜色等设置。
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Advanced Strategies -->
        <div class="bg-gradient-to-r from-purple-50 to-indigo-50 rounded-lg p-8 mb-12">
            <h2 class="text-2xl font-bold mb-6 text-gray-800">
                <i class="fas fa-rocket mr-2 text-purple-600"></i>
                高级优化策略
            </h2>
            <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
                <div class="bg-white rounded-lg p-6">
                    <div class="text-purple-600 text-3xl mb-3">
                        <i class="fas fa-sync-alt"></i>
                    </div>
                    <h3 class="font-bold text-lg mb-2">异步处理</h3>
                    <p class="text-gray-700 text-sm">
                        将 Excel 生成放入后台任务，避免长时间阻塞操作，提升用户体验。
                    </p>
                </div>
                <div class="bg-white rounded-lg p-6">
                    <div class="text-purple-600 text-3xl mb-3">
                        <i class="fas fa-chart-line"></i>
                    </div>
                    <h3 class="font-bold text-lg mb-2">性能监控</h3>
                    <p class="text-gray-700 text-sm">
                        监控 CPU、内存和磁盘 I/O，找出性能瓶颈并进行针对性优化。
                    </p>
                </div>
                <div class="bg-white rounded-lg p-6">
                    <div class="text-purple-600 text-3xl mb-3">
                        <i class="fas fa-network-wired"></i>
                    </div>
                    <h3 class="font-bold text-lg mb-2">分布式处理</h3>
                    <p class="text-gray-700 text-sm">
                        将大规模导出任务分布到多个服务器，通过负载均衡提升处理能力。
                    </p>
                </div>
            </div>
        </div>

        <!-- Best Practices -->
        <div class="bg-white rounded-lg shadow-lg p-8">
            <h2 class="text-2xl font-bold mb-6 text-gray-800">
                <i class="fas fa-lightbulb mr-2 text-yellow-500"></i>
                最佳实践建议
            </h2>
            <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                <div class="flex items-start">
                    <i class="fas fa-compress text-blue-600 mt-1 mr-3"></i>
                    <div>
                        <h4 class="font-bold mb-1">文件压缩</h4>
                        <p class="text-gray-700 text-sm">
                            对于超大 Excel 文件，考虑压缩成 ZIP 格式，减少传输和存储负担。
                        </p>
                    </div>
                </div>
                <div class="flex items-start">
                    <i class="fas fa-plus-circle text-green-600 mt-1 mr-3"></i>
                    <div>
                        <h4 class="font-bold mb-1">增量生成</h4>
                        <p class="text-gray-700 text-sm">
                            实现增量生成功能，用户只下载所需部分数据，减少文件大小。
                        </p>
                    </div>
                </div>
                <div class="flex items-start">
                    <i class="fas fa-code text-purple-